<?php
/**
 * Created by PhpStorm.
 * User: zhuyujun
 * Date: 2017/10/24
 * Time: 15:21
 */

namespace App\Api\Service\Test\Controllers;


use Framework\BaseClass\Api\Controller;
use Illuminate\Http\Request;
use App\Api\Service\Test\Models\Models;


class IndexController extends Controller
{
    public function getOrderDetailTemplate(Request $request){

        //获取传入数据
        header('Content-type: application/json');
        return '{"idName":1,"type":"viewGroup","bgColor":"#F8F8F8","data":[{"idName":2,"type":"button","title":"$buttonTitle2","fontColor":"#000000","fontSize":15,"bgColor":"#FFFFFF","bgImage":"http://button1.png","functionName":"detailAction","frame":{"x":0,"y":0,"w":187.5,"h":50}},{"idName":3,"type":"button","fontSize":15,"fontColor":"#000000","title":"$buttonTitle3","bgColor":"#FFFFFF","bgImage":"http://button3.png","functionName":"exampleAction","frame":{"x":187.5,"y":0,"w":187.5,"h":50}},{"idName":5,"type":"scrollView","bgColor":"#F8F8F8","sliderHiden":"YES","frame":{"x":0,"y":60,"w":375,"h":557},"contentSize":{"w":375,"h":2500},"data":[{"idName":6,"type":"viewGroup","bgColor":"#FFFFFF","frame":{"x":0,"y":0,"w":375,"h":400},"data":[{"idName":11,"type":"label","bgColor":"#FFFFFF","title":"$titleLabelValue0","fontSize":15,"fontColor":"#000000","frame":{"x":15,"y":10,"w":100,"h":30}},{"idName":12,"type":"view","bgColor":"#F0F0F0","frame":{"x":0,"y":59,"w":375,"h":1}},{"idName":13,"type":"viewGroup","bgColor":"#FFFFFF","frame":{"x":0,"y":60,"w":375,"h":320},"command":{"type":"loop","dataSource":"$list0"},"data":[{"idName":14,"type":"label","fontSize":13,"fontColor":"#B5B5B5","bgColor":"#FFFFFF","title":"$leftLabelValue","frame":{"x":15,"y":10,"w":100,"h":40}},{"idName":15,"type":"label","fontSize":13,"fontColor":"#000000","bgColor":"#FFFFFF","title":"$rightLabelValue","frame":{"x":110,"y":10,"w":265,"h":40}}]}]},{"idName":16,"type":"viewGroup","bgColor":"#FFFFFF","frame":{"x":0,"y":410,"w":375,"h":340},"data":[{"idName":17,"type":"label","bgColor":"#FFFFFF","title":"$titleLabelValue1","fontSize":15,"fontColor":"#000000","frame":{"x":15,"y":10,"w":100,"h":30}},{"idName":18,"type":"view","bgColor":"#F8F8F8","frame":{"x":0,"y":59,"w":375,"h":1}},{"idName":19,"type":"viewGroup","bgColor":"#FFFFFF","frame":{"x":0,"y":60,"w":375,"h":240},"command":{"type":"loop","dataSource":"$list1"},"data":[{"idName":20,"type":"label","fontSize":13,"fontColor":"#B5B5B5","bgColor":"#FFFFFF","title":"$leftLabelValue","frame":{"x":15,"y":10,"w":100,"h":40}},{"idName":21,"type":"label","fontSize":13,"fontColor":"#000000","bgColor":"#FFFFFF","title":"$rightLabelValue","frame":{"x":110,"y":10,"w":265,"h":40}}]}]},{"idName":22,"type":"viewGroup","bgColor":"#FFFFFF","frame":{"x":0,"y":760,"w":375,"h":380},"data":[{"idName":23,"type":"label","bgColor":"#FFFFFF","title":"$titleLabelValue2","fontSize":15,"fontColor":"#000000","frame":{"x":15,"y":10,"w":100,"h":30}},{"idName":24,"type":"view","bgColor":"#F8F8F8","frame":{"x":0,"y":59,"w":375,"h":1}},{"idName":25,"type":"viewGroup","bgColor":"#FFFFFF","frame":{"x":0,"y":60,"w":375,"h":280},"command":{"type":"loop","dataSource":"$list2"},"data":[{"idName":26,"type":"label","fontSize":13,"fontColor":"#B5B5B5","bgColor":"#FFFFFF","title":"$leftLabelValue","frame":{"x":15,"y":10,"w":100,"h":40}},{"idName":27,"type":"label","fontSize":13,"fontColor":"#000000","bgColor":"#FFFFFF","title":"$rightLabelValue","frame":{"x":110,"y":10,"w":265,"h":40}}]}]},{"idName":28,"type":"viewGroup","bgColor":"#FFFFFF","frame":{"x":0,"y":1150,"w":375,"h":680},"data":[{"idName":29,"type":"label","bgColor":"#FFFFFF","title":"$titleLabelValue3","fontSize":15,"fontColor":"#000000","frame":{"x":15,"y":10,"w":100,"h":30}},{"idName":30,"type":"view","bgColor":"#F8F8F8","frame":{"x":0,"y":59,"w":375,"h":1}},{"idName":31,"type":"viewGroup","bgColor":"#FFFFFF","frame":{"x":0,"y":60,"w":375,"h":560},"command":{"type":"loop","dataSource":"$list3"},"data":[{"idName":32,"type":"label","fontSize":13,"fontColor":"#B5B5B5","bgColor":"#FFFFFF","title":"$leftLabelValue","frame":{"x":15,"y":10,"w":100,"h":40}},{"idName":33,"type":"label","fontSize":13,"fontColor":"#000000","bgColor":"#FFFFFF","title":"$rightLabelValue","frame":{"x":110,"y":10,"w":265,"h":40}}]}]},{"idName":34,"type":"viewGroup","bgColor":"#FFFFFF","frame":{"x":0,"y":1840,"w":375,"h":560},"data":[{"idName":35,"type":"label","bgColor":"#FFFFFF","title":"$titleLabelValue4","fontSize":15,"fontColor":"#000000","frame":{"x":15,"y":10,"w":100,"h":30}},{"idName":36,"type":"view","bgColor":"#F8F8F8","frame":{"x":0,"y":59,"w":375,"h":1}},{"idName":37,"type":"viewGroup","bgColor":"#FFFFFF","frame":{"x":0,"y":60,"w":375,"h":480},"command":{"type":"loop","dataSource":"$list4"},"data":[{"idName":38,"type":"label","fontSize":13,"fontColor":"#B5B5B5","bgColor":"#FFFFFF","title":"$leftLabelValue","frame":{"x":15,"y":10,"w":100,"h":40}},{"idName":39,"type":"label","fontSize":13,"fontColor":"#000000","bgColor":"#FFFFFF","title":"$rightLabelValue","frame":{"x":110,"y":10,"w":265,"h":40}}]}]},{"idName":40,"type":"button","fontColor":"#000000","bgColor":"#FFFFFF","frame":{"x":40,"y":2410,"w":295,"h":60},"functionName":"printAction","title":"$buttonTitle40","bgImage":"http://buttonBack.png"}]}],"frame":{"x":0,"y":0,"w":375,"h":667}}';


    }

    public function getOrderDetailData(Request $request){

        //获取传入数据
        $input = $request->all();
        //获取主工单数据
        $orderId = $input['id'];
        $models = new Models();
        $orderInfo = $models->getOrderInfo($orderId)->toArray();

        //获取工单基础信息
        $orderBasicInfo = $models->getOrderBasicInfo($orderId)->toArray();

        //获取工单生成品类信息
        $orderProductionCategoryInfo = $models->getOrderProductionCategoryInfo($orderId)->toArray();

        //获取工单彩印工序信息
        $orderColourPrintingInfo = $models->getOrderColourPrintingInfo($orderId)->toArray();

        //获取工单复合工序
        $orderCompositeInfo = $models->getOrderCompositeInfo($orderId)->toArray();

        //后加工工序
        $orderPostProcessingInfo = $models->getOrderPostProcessingInfo($orderId)->toArray();



        header('Content-type: application/json');
        $returnArr = [
            '$buttonTitle2'=>'工序单详情',
            '$buttonTitle3'=>'实例图',
            '$titleLabelValue0'=>'基本信息',
            '$list0'=>[
                [
                    '$leftLabelValue'=>'客户',
                    '$rightLabelValue'=>$orderBasicInfo[0]['customer_name']
                ],
                [
                    '$leftLabelValue'=>'品名',
                    '$rightLabelValue'=>$orderBasicInfo[0]['product_name']
                ],
                [
                    '$leftLabelValue'=>'下单日期',
                    '$rightLabelValue'=>$orderBasicInfo[0]['created_at']
                ],
                [
                    '$leftLabelValue'=>'交货日期',
                    '$rightLabelValue'=>$orderBasicInfo[0]['finished_date']
                ],
                [
                    '$leftLabelValue'=>'数量',
                    '$rightLabelValue'=>$orderBasicInfo[0]['product_num'].'条'
                ],
                [
                    '$leftLabelValue'=>'片料规格',
                    '$rightLabelValue'=>$orderBasicInfo[0]['chip_specification']
                ],
                [
                    '$leftLabelValue'=>'成品规格',
                    '$rightLabelValue'=>$orderBasicInfo[0]['finished_specification']
                ],
                [
                    '$leftLabelValue'=>'成品重量',
                    '$rightLabelValue'=>$orderBasicInfo[0]['finished_weight']
                ]
            ],
            '$titleLabelValue1'=>'生产品类',
            '$list1'=>[
                [
                    '$leftLabelValue'=>'编织袋种类',
                    '$rightLabelValue'=> $orderProductionCategoryInfo[0]['woven_bags_type']
                ],
                [
                    '$leftLabelValue'=>'宽度',
                    '$rightLabelValue'=>$orderProductionCategoryInfo[0]['width']
                ],
                [
                    '$leftLabelValue'=>'颜色',
                    '$rightLabelValue'=>$orderProductionCategoryInfo[0]['color']
                ],
                [
                    '$leftLabelValue'=>'克重',
                    '$rightLabelValue'=>$orderProductionCategoryInfo[0]['weight'].'g'
                ],
                [
                    '$leftLabelValue'=>'拉力',
                    '$rightLabelValue'=>$orderProductionCategoryInfo[0]['pull'].'N'
                ],
                [
                    '$leftLabelValue'=>'扣数',
                    '$rightLabelValue'=>$orderProductionCategoryInfo[0]['thread_num']
                ]
            ],
            '$titleLabelValue2'=>'彩印工序',
            '$list2'=>[
                [
                    '$leftLabelValue'=>'膜',
                    '$rightLabelValue'=> $orderColourPrintingInfo[0]['membrane']
                ],
                [
                    '$leftLabelValue'=>'厚度',
                    '$rightLabelValue'=>$orderColourPrintingInfo[0]['thickness']
                ],
                [
                    '$leftLabelValue'=>'宽度',
                    '$rightLabelValue'=>$orderColourPrintingInfo[0]['width']
                ],
                [
                    '$leftLabelValue'=>'版面',
                    '$rightLabelValue'=>$orderColourPrintingInfo[0]['position']
                ],
                [
                    '$leftLabelValue'=>'颜色只数',
                    '$rightLabelValue'=>''
                ],
                [
                    '$leftLabelValue'=>'粘合面数',
                    '$rightLabelValue'=>$orderColourPrintingInfo[0]['adhesive_surface_num']
                ],
                [
                    '$leftLabelValue'=>'备注',
                    '$rightLabelValue'=>$orderColourPrintingInfo[0]['remark']
                ]
            ],
            '$titleLabelValue3'=>'复合工序',
            '$list3'=>[
                [
                    '$leftLabelValue'=>'用料',
                    '$rightLabelValue'=>$orderCompositeInfo[0]['materials']
                ],
                [
                    '$leftLabelValue'=>'克重',
                    '$rightLabelValue'=>$orderCompositeInfo[0]['weight'].'g'
                ],
                [
                    '$leftLabelValue'=>'数量',
                    '$rightLabelValue'=>'6000条'
                ],
                [
                    '$leftLabelValue'=>'数量',
                    '$rightLabelValue'=>'6000条'
                ],
                [
                    '$leftLabelValue'=>'成品重量',
                    '$rightLabelValue'=>'137g'
                ]
            ],
            '$buttonTitle40'=>'打印入库'
        ];

        return \GuzzleHttp\json_encode($returnArr);


    }

}